<?php

namespace app\api\model;

use traits\model\SoftDelete;

class MerchantModel extends BaseModel
{
    use SoftDelete;

    protected $pk = 'id';
    protected $table = 'hs_merchant';
    protected static $tableName = 'merchant';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';


    //状态常量
    const STATUS_DEFAULT = 0;//待审核
    const STATUS_SUCCESS = 1;//审核通过
    const STATUS_FAIL = 2;//审核失败


    public static function check($user_id)
    {
        $model = self::where('user_id', $user_id)->find();
        if (!$model) {
            return array('code' => 1, 'model' => '');
        }
        if ($model['status'] == self::STATUS_DEFAULT) {
            return array('code' => -1, 'msg' => '您已提交过审核，正在审核中');
        }
        if ($model['status'] == self::STATUS_SUCCESS) {
            return array('code' => -1, 'msg' => '您已提交过审核，请勿重复提交');
        }
        return array('code' => 1, 'model' => $model);
    }
}